package 剑指offer;

public class p53_II0到n减1中缺失的数字 {
    public int missingNumber(int[] nums) {
        int left=0;
        int right=nums.length-1;

        while (left<=right) {
            int mid=(left+right)/2;

            if (nums[mid]==mid) {
                //则当前中间位置的元素和索引对应，则左区间正常，查找的元素在右区间
                left=mid+1;
            }else {
                //则当前中间位置的元素和索引不对应，则左区间不正常
                right=mid-1;
            }
        }
        return left;
    }
}
